package com.moduleSys.cms.role;

import com.moduleSys.entity.system.Menu;
import com.moduleSys.entity.system.Role;
import com.moduleSys.entity.system.RoleMenu;
import com.moduleSys.roleService.RoleService;
import com.moduleSys.utils.json.JsonResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by czw on 2017/7/19 0019.
 */
@RestController
@RequestMapping(value = "/role")
public class RoleController {
    private static final Logger logger = LoggerFactory.getLogger(RoleController.class);

    @Autowired
    private RoleService roleService;

    @RequestMapping(value = "/addRole",method = {RequestMethod.GET,RequestMethod.POST})
    public JsonResult addUser(Role role,String mId){
        roleService.insert(role,mId);
        return new JsonResult(1,null,null);
    }

    @RequestMapping(value = "/list",method = {RequestMethod.GET,RequestMethod.POST})
    public JsonResult list(Integer pageSize,Integer currentPage){
        JsonResult jr = roleService.list(pageSize,currentPage);
        return jr;
    }
    @RequestMapping(value = "/deleteBatch",method = {RequestMethod.GET,RequestMethod.POST})
    public JsonResult deleteBatch(@RequestParam(value = "itemIds[]",required = false) Long[] itemIds){
        JsonResult jr = roleService.deleteBatch(itemIds);
        return jr;
    }

    @RequestMapping(value = "/updateRole",method = {RequestMethod.GET,RequestMethod.POST})
    public JsonResult updateRole(Role role,String mId){
        JsonResult jr = roleService.updateRole(role,mId);
        return jr;
    }

    @RequestMapping(value = "/getRoleList",method = {RequestMethod.GET,RequestMethod.POST})
    public JsonResult getRoleList(){
        JsonResult jr = roleService.getRoleList();
        return jr;
    }
}
